<template>
  <div>
    <div>
      <van-nav-bar title="生活数据" left-arrow @click-left="gohome">
        <template #right>
          <van-icon name="ellipsis" />
        </template>
      </van-nav-bar>
    </div>
    <div class="my_shucontent">
      <div>
        <span class="my_shu">数据统计</span>
        <p class="my_nin">您家的每日数据统计</p>
      </div>
      <div class="my_fontlist">
        <div class="fontbox">
          <span class="">+</span>
        </div>
        <div class="fontbox">
          <span class="iconfont icon-chuang"></span>
        </div>
        <div class="fontbox">
          <span class="iconfont icon-deng"></span>
        </div>
        <div class="fontbox">
          <span class="iconfont icon-linyu"></span>
        </div>
      </div>
      <div class="my_shuboton">
        <span class="my_shu">费用</span>
        <p class="my_nin">最小化成本</p>
      </div>
      <div class="my_tilist">
        <div class="my_tilist1">
          今日
        </div>
        <div class="my_tilist1">
          按周
        </div>
        <div class="my_tilist1">
          按月
        </div>
        <div class="my_tilist1">
          按年
        </div>
      </div>
      <div>
        <div ref="barChart" :style="{ width: '110x', height: '250px' }"></div>
      </div>
      <div class="my_liang">
        <div>
          <span class="my_zuo">昨日</span>
          <p class="my_price">19.89元</p>
        </div>
        <div>
          <span class="my_zuo">今日</span>
          <p class="my_price">19.89元</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import router from '@/router';
import * as echarts from 'echarts';
import { onMounted, ref } from 'vue';



const gohome = () => {
  router.push('./Hello')
}

const barChart = ref<HTMLElement>();
const myChart1 = ref<any>();
// 绘制柱形图
function initBarEcharts() {
  myChart1.value = echarts.init(barChart.value!);
  myChart1.value.setOption({
    title: {

      x: 'center'
    },
    tooltip: {
      trigger: 'item'
    },
    legend: {

      orient: 'vertical',
      right: 60,
      top: 20
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
      show: false
    },
    yAxis: {
      type: 'value',
      show: false
    },
    color: ['#7033ff', '#7033ff'],
    series: [
      {
        smooth: true,
        data: [20, 50, 80, 30, 150, 50, 280],
        type: 'line',
        areaStyle: {}
      }
    ],
    grid: {
      x: 0,
      y: 0,
      x2: 0,
      y2: 20,
      borderWidth: 1
    }
  });
}
onMounted(() => {
  initBarEcharts();
});

</script>

<style scoped lang="scss">
.my_shucontent {
  padding: 1rem;

  .my_shu {
    color: #352C5D;
    font-family: "uniqueID∞version∞PingFangSC∞Semibold";
    font-size: 2rem;
    font-weight: 400;
    line-height: 4rem;
  }

  .my_nin {
    color: #ABA3CF;
  }

  .my_fontlist {
    width: 26rem;
    height: 4.8rem;
    display: flex;
    justify-content: space-around;
    margin-top: 4rem;

  }

  .box {
    padding: 0.8rem;
    background-color: #FFFFFF;
  }

  .fontbox {
    width: 4.8rem;
    height: 4.8rem;
    background-color: #F6F5FA;
    color: #ABA3CF;
    font-size: 3rem;
    line-height: 5rem;
    text-align: center;
    border-radius: 1.5rem;

  }

  .fontbox:hover {
    background-color: #7033FF;
    color: white;
  }

  .my_shuboton {
    height: 8rem;
    border-bottom: 0.1rem solid #ABA3CF;
  }

  .my_tilist {
    display: flex;
    justify-content: space-around;

    .my_tilist1 {
      width: 6.8rem;
      height: 3.2rem;
      margin-top: 1rem;
      border-radius: 3rem;
      color: #352C5D;
      text-align: center;
      line-height: 3rem;
    }

    .my_tilist1:hover {
      color: white;
      background-color: #352C5D;
    }
  }

  .my_liang {
    display: flex;
    justify-content: space-between;
    align-items: center;
    justify-content: space-around;

    .my_zuo {
      font-size: 2.5rem;
      line-height: 3rem;
    }

    .my_price {
      color: #ABA3CF;
      font-size: 2rem;
    }
  }


}
</style>